import {arrConvert2Tree} from "st-common-core"

const menus = [
    {
        "id": 1,
        "name": "首页",
        "parentId": null,
        arr: [1111, 2222, 3333]
    },
    {
        "id": 2,
        "name": "用户管理",
        "parentId": null
    },
    {
        "id": 3,
        "name": "角色管理",
        "parentId": null
    },
    {
        "id": 4,
        "name": "设置",
        "parentId": null
    },
    {
        "id": 5,
        "name": "添加用户",
        "parentId": 2
    },
    {
        "id": 6,
        "name": "查看用户",
        "parentId": 2
    },
    {
        "id": 7,
        "name": "添加角色",
        "parentId": 3
    },
    {
        "id": 8,
        "name": "查看角色",
        "parentId": 3
    },
    {
        "id": 9,
        "name": "系统设置",
        "parentId": 4
    },
    {
        "id": 10,
        "name": "权限设置",
        "parentId": 4
    }
]

const menuTree = arrConvert2Tree(menus, 'id', 'parentId')
console.log(menuTree)

menuTree[0].name = '首页111'
console.log(menus, menuTree)

menuTree[0].arr.push(4444)
menuTree[0].arr[0] = 5555
console.log(menus, menuTree)